<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/WEB-INF/struts-tags.tld"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>欢迎访问产品运营互动中心！</title>

<script src="<s:url value="/script/jquery_last.js"/>" type="text/javascript"></script>
<script src="<s:url value="/script/formValidator.js"/>" type="text/javascript" charset="UTF-8"></script>
<script src="<s:url value="/script/formValidatorRegex.js"/>" type="text/javascript" charset="UTF-8"></script>
<script language="javascript" src="<s:url value="/script/DateTimeMask.js"/>" type="text/javascript"></script>
<script type="text/javascript" src="<s:url value="/script/selfResize.js"/>"></script>
<script>
function show(url){
	window.open(url);
}
function initLoad(){
	f_iframeResize();
}
</script>
<script type="text/javascript">
$(document).ready(function(){
	$.formValidator.initConfig({autotip:true,onerror:function(msg){alert(msg)}});
	$("input:text[name='processConfigDetail.name']").formValidator({tipid:"nametip",onshow:"节点名称"}).inputValidator({min:1,onerror:"您还没有输入节点名称",empty:{leftempty:false,rightempty:false,emptyerror:"节点名称两边不能有空符号"}});
});
</script>


<link rel="stylesheet" href="<s:url value="/css/style_new.css"/>">
<link rel="stylesheet" href="<s:url value="/css/validator.css"/>">
<link href="<s:url value="/images/08_ccxxzx.css"/>" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0">
<table width="980" border="0" cellspacing="0" cellpadding="0" align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td>
			<table width="100%" border="0" cellpadding="0" cellspacing="0"
				background="<s:url value="/images/new/gxzl_index_2.gif"/>">
				<tr>
					<td width="20" height="32">&nbsp;</td>
					<td width="20"><img
						src="<s:url value="/images/new/dq_dot.gif"/>" width="15"
						height="12" /></td>
					<td>当前位置：流程节点配置</td>
					<!--td width="100">流程节点搜索</td>
					<td width="200"><input name="conds.name" type="text"
						style="width: 99%" value="${conds.name}" onFocus="this.value=''" /></td>
					<td width="100"><input type="submit" name="Submit" value="搜索" /></td-->
				</tr>
			</table>
			</td>
		</tr>
	<tr>
		<td background="<s:url value="/images/home_4a.gif"/>">
		<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
			<tr>
		    <td  background="<s:url value="/images/home_4a.gif"/>"> 
		      <table width="100%" height="400" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
		        <tr>
		          <td width="240" valign="top" class="leftbg">
					<%@ include file="/commons/include/bpm_left.inc"%>  
				  </td>
		          <td valign="top">
						<s:form action="saveProcessConfigDetail.action"
							namespace="/security" method="post" enctype="multipart/form-data" 
						    onsubmit="return (fill()&&$.formValidator.pageIsValid('1'));">
							<input type="hidden" name="processConfigDetail.id"
								value="${processConfigDetail.id}">
							<table width="98%" align="center" border="0" cellspacing="0" cellpadding="0">
								<br/>
								<tr>
									<td height="5">
										<table width="100%" border="0" cellspacing="0" cellpadding="0">
											<tr>
												<td width="5" height="5"><img src="<s:url value="/images/cphdzx_tab1.gif"/>" width="5" height="5" /></td>
												<td class="tdborderup"><img src="<s:url value="/images/spacer.gif"/>" width="1" height="1" /></td>
												<td width="5"><img src="<s:url value="/images/cphdzx_tab2.gif"/>" width="5" height="5" /></td>
											</tr>
										</table>
									</td>
								</tr>
								<tr>
									<td  class="tdborderleftright">
									<TABLE width="98%" cellSpacing=1 cellPadding=0 align="center">
										<TR height=30>
											<TD align=left width="10%"><input type="submit" IsShowProcessBar="True" name="Submit" value="保 存"> <input type="button"
												value="返 回" onClick="location.href='processConfigDetail.action'">
											</TD>
										</TR>
									</table>
									<s:if test="#returnMsg==null">
										
									</s:if> <s:else>
										<TABLE width="98%" cellSpacing=1 cellPadding=0 align="center">
											<TR height=30>
												<TD align=left width="10%"><font color="red">${returnMsg}</font>
												</TD>
											</TR>
										</table>
									</s:else>
									<table width="98%" border="0" cellspacing="0" cellpadding="7"
										align="center" class=tablecolor2>
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right"><font color="red">*</font>节点名称：</div>
									</td>
									<td width="81%"><s:textfield name="processConfigDetail.name" theme="css_xhtml" size="50"/>
									<div id="nametip" style="width:auto"></div></td>
								</tr>
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">节点类型：</div>
									</td>
									<td width="81%">
										<select id="processConfigDetail.nodeType" name="processConfigDetail.nodeType" style="width:155px">
											<option value="2">过程</option>
											<option value="0">开始</option>
											<option value="1">结束</option>
											<option value="3">分发</option>
											<option value="4">合并</option>
										</select>
									</td>
								</tr>
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right"><font color="red">*</font>所属流程：</div>
									</td>
									<td width="81%"><s:select id="processConfigDetail.processConfig.id" name="processConfigDetail.processConfig.id" list="processConfigs"
										listKey="id" listValue="name" theme="css_xhtml" cssStyle="width:200px" onchange="changeNextTep()"/></td>
								</tr>
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">流程步骤：</div>
									</td>
									<td width="81%"><s:select name="processConfigDetail.processStep.id" list="processSteps"
										listKey="id" listValue="name" theme="css_xhtml" /></td>
								</tr>
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">办理人类型：</div>
									</td>
									<td width="81%"><s:select name="processConfigDetail.transactorType.id" list="transactorTypes"
										listKey="id" listValue="name" theme="css_xhtml" /></td>
								</tr>								
																																
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">要求时限天数：</div>
									</td>
									<td width="81%">
										<input type="text" name="processConfigDetail.timeLimit" value="${processConfigDetail.timeLimit}" size="10" onkeydown=""> 天
									</td>
								</tr>
								
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">流程事项说明：</div>
									</td>
									<td width="81%">
											<s:textarea name="processConfigDetail.flowExplain" theme="css_xhtml" cols="70" rows="4" />
									</td>
								</tr>
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">处理时限说明：</div>
									</td>
									<td width="81%">
											<s:textarea name="processConfigDetail.limitExplain" theme="css_xhtml" cols="70" rows="4" />
									</td>
								</tr>
								
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">下一步骤：</div>
									</td>
									<td width="81%">
										
							<table border="0" width="100%">
							<tr>
							  <td valign="top">
							    	<select name="newConfig" id="newConfig" style="width:160px;height:150px" property="id" labelProperty="name" multiple>
								   </select>
				                </td>
				                <td aling="center" width="20"  valign="middle">
				                <input type="button" value="添加节点" onclick="addOption(document.all['newConfig'],document.all['nextConfig']);">
				                <br> 
				                <input type="button" value="删除节点" onclick="addOption(document.all['nextConfig'],document.all['newConfig']);">
				                </td>
				                <td aling="center" valign="top">
				           <select name="nextConfig" id="nextConfig" style="width:160px;height:150px" property="product" labelProperty="productName" multiple>
								   </select>
				        </td>
			        </tr>

			        
			        
			       	</table>
			       	
									</td>
								</tr>
								
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">上传文档类型：</div>
									</td>
									<td width="81%">
										
								<table border="0" width="100%">
								<tr>
								  <td valign="top">
					           <select name="allDocType" id="allDocType" style="width:160px;height:150px" multiple>
					           	<s:iterator value="lRefType" status="st">
					           		<option value="<s:property value="id"/>"><s:property value="name"/></option>
					           	</s:iterator>
									   </select>
					                </td>
					                <td aling="center" width="20"  valign="middle">
					                <input type="button" value="添加文档类型" onclick="addOption(document.all['allDocType'],document.all['docType']);">
					                <br> 
					                <input type="button" value="删除文档类型" onclick="addOption(document.all['docType'],document.all['allDocType']);">
					                </td>
					                <td aling="center" valign="top">
					           <select name="docType" id="docType" style="width:160px;height:150px" multiple>
					           	<s:iterator value="documentTypes" status="st">
					           		<option value="<s:property value="docType.id"/>"><s:property value="docType.name"/></option>
					           	</s:iterator>
									   </select>
					        </td>
				        </tr>
				        
				       	</table>
			       	
									</td>
								</tr>
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">节点角色分配：</div>
									</td>
									<td width="81%">
											<input type="text" name="processConfigDetail.secRole" value="${processConfigDetail.secRole}" style="width: 95%">
									</td>
								</tr>
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">节点泳道：</div>
									</td>
									<td width="81%">
											<input type="text" name="processConfigDetail.swinlane" value="${processConfigDetail.swinlane}" style="width: 95%">
									</td>
								</tr>
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">节点人员分配接口：</div>
									</td>
									<td width="81%">
											<input type="text" name="processConfigDetail.assignHandlerClass" value="${processConfigDetail.assignHandlerClass}" style="width: 95%">
									</td>
								</tr>								
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">节点排序：</div>
									</td>
									<td width="81%">
											<input type="text" name="processConfigDetail.orderBy" value="${processConfigDetail.orderBy}" style="width: 95%">
									</td>
								</tr>
								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">节点URL：</div>
									</td>
									<td width="81%">
											<input type="text" name="processConfigDetail.url" value="${processConfigDetail.url}" style="width: 95%">
									</td>
								</tr>

								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">节点条件：</div>
									</td>
									<td width="81%">
											<input type="text" name="processConfigDetail.condition" value="${processConfigDetail.condition}" style="width: 95%">
									</td>
								</tr>

								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">节点X坐标：</div>
									</td>
									<td width="81%">
											<input type="text" name="processConfigDetail.nodeX" value="${processConfigDetail.nodeX}" style="width: 95%">
									</td>
								</tr>

								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">节点Y坐标：</div>
									</td>
									<td width="81%">
											<input type="text" name="processConfigDetail.nodeY" value="${processConfigDetail.nodeY}" style="width: 95%">
									</td>
								</tr>

								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">节点长度：</div>
									</td>
									<td width="81%">
											<input type="text" name="processConfigDetail.nodeW" value="${processConfigDetail.nodeW}" style="width: 95%">
									</td>
								</tr>

								<tr>
									<td width="19%" bgcolor="D6E3FA">
									<div align="right">节点宽度：</div>
									</td>
									<td width="81%">
											<input type="text" name="processConfigDetail.nodeH" value="${processConfigDetail.nodeH}" style="width: 95%">
									</td>
								</tr>																																								
										<input type="hidden" name="processConfigDetail.creator"
											value="${processConfigDetail.creator}">
										<input type="hidden" name="processConfigDetail.createTime"
											value="<s:date name="processConfigDetail.createTime" format="yyyy-MM-dd HH:mm"/>">
										<input type="hidden" name="processConfigDetail.begin"
											value="<s:date name="processConfigDetail.begin" format="yyyy-MM-dd HH:mm"/>">
										<input type="hidden" name="processConfigDetail.end"
											value="<s:date name="processConfigDetail.end" format="yyyy-MM-dd HH:mm"/>">
										<input type="hidden" id="newConfigIds" name="newConfigIds" value="">
										<input type="hidden" id="docTypeIds" name="docTypeIds" value="">
												
									</table>
									</td>
								</tr>
								<tr>
									<td height="5">
										<table width="100%" border="0" cellspacing="0" cellpadding="0">
											<tr>
												<td width="5" height="5"><img src="<s:url value="/images/cphdzx_tab3.gif"/>" width="5" height="5" /></td>
												<td class="tdborderbottom"><img src="<s:url value="/images/spacer.gif"/>" width="1" height="1" /></td>
												<td width="5"><img src="<s:url value="/images/cphdzx_tab4.gif"/>" width="5" height="5" /></td>
											</tr>
										</table>
									</td>
								</tr>
							</table></td>
					</tr>
				</table>
				</s:form> 
</body>
</html>
<script>
function setSelected(obj,val){
	if(obj&&val){
		for(var i=0;i<obj.options.length;i++){
			if(obj.options[i].value==val){
				obj.options[i].selected=true;
			}
		}
	}
}
var val=${processConfigDetail.nodeType}+"";
setSelected(document.forms[0]["processConfigDetail.nodeType"],val);

var detailList=new Array();
var nextTepList=new Array();
<s:iterator value="processConfigDetails" status="st">
detailList[<s:property value="#st.getIndex()"/>]=new Array("<s:property value="id"/>","<s:property value="name"/>","<s:property value="processConfig.id"/>");
</s:iterator>
<s:iterator value="nextTeps" status="st">
nextTepList[<s:property value="#st.getIndex()"/>]="<s:property value="nextConfig.id"/>";
</s:iterator>
var detailId=${processConfigDetail.id}+"";
var list1=document.all["newConfig"];
var list2=document.all["nextConfig"];
function changeNextTep(){
	var processConfig=document.all["processConfigDetail.processConfig.id"].value;
	var nextTep=document.all["newConfig"];
	setNextTepByConfig(processConfig);
}
function setNextTepByConfig(processConfig){
	clearList(list1);
	clearList(list2);
	if(list1&&processConfig&&detailList&&detailList.length>0){
		for(var i=0;i<detailList.length;i++){
			if(detailList[i]){
				if(detailList[i][2]==processConfig&&detailId!=detailList[i][0]){
				  var myOption=document.createElement("option");
				  myOption.setAttribute("value",detailList[i][0]);
				  myOption.appendChild(document.createTextNode(detailList[i][1]));
				  if(isSelected(detailList[i][0])){
				  	list1.appendChild(myOption);
				  }else{
				  	list2.appendChild(myOption);
				  }
				}
			}
		}
	}
}
function isSelected(val){
	if(nextTepList&&nextTepList.length>0){
		for(var i=0;i<nextTepList.length;i++){
			if(nextTepList[i]==val){
				return false;
			}
		}
	}
	return true;
}
function clearList(sel){
	if(sel&&sel.options&&sel.options.length>0){
		for(var i=sel.options.length;i>0;i--){
			sel.removeChild(sel.options[i-1]);
		}
	}
}
function addOption(list1,list2){
	for(var i=list1.options.length;i>0;i--){
		if(list1.options[i-1].selected==true){
			list2.appendChild(list1.options[i-1]);
		}
	}
}
changeNextTep();

function fill(){
	var sel=document.all["nextConfig"];
	var val="";
	if(sel&&sel.options&&sel.options.length>0){
		for(var i=sel.options.length;i>0;i--){
			val=val+"#"+sel.options[i-1].value;
		}
		if(val!=""){
			val=val.substring(1);
		}
	}
	document.all["newConfigIds"].value=val;
	
	var doc=document.all["docType"];
	var docVal="";
	if(doc&&doc.options&&doc.options.length>0){
		for(var i=doc.options.length;i>0;i--){
			docVal=docVal+"#"+doc.options[i-1].value;
		}
		if(docVal!=""){
			docVal=docVal.substring(1);
		}
	}
	document.all["docTypeIds"].value=docVal;
	
	var timeLimit=document.all["processConfigDetail.timeLimit"];
	if(timeLimit&&timeLimit.value.length>0){
		var filter=/^([0-9])+$/;
		if(!filter.test(timeLimit.value)){
			alert("要求时限天数只能输入数字，请重新输入！");
			
			return false;
		}
	}
}

{
	var sour=document.all['allDocType'];
	var obj=document.all['docType'];
	var i=j=0;
	for(i=sour.options.length;i>0;i--){
		for(j=obj.options.length;j>0;j--){
			if(sour.options[i-1].value==obj.options[j-1].value)
				sour.removeChild(sour.options[i-1]);
		}
	}
}

window.onload = initLoad;

</script>